"""
营销 - 商户活动修改服务
"""

from jlpay.services.base_service import BaseService
from jlpay.model.marketing.merchant_activity_update import (
    MerchantActivityUpdateRequest, MerchantActivityUpdateResponse
)


class MerchantActivityUpdateService(BaseService):
    """商户活动修改服务"""
    
    def __init__(self, config):
        """
        初始化商户活动修改服务
        
        Args:
            config: OrgConfig实例
        """
        super().__init__(config)
    
    def get_api_url(self, request_class, api_path=None):
        """
        获取API URL
        
        Args:
            request_class: 请求类
            api_path: 接口路径
            
        Returns:
            完整的API URL
        """
        base_url = self.config.url
        
        if api_path:
            return f"{base_url}{api_path}"
        
        # 使用Request类中定义的path()方法
        if hasattr(request_class, 'path') and callable(getattr(request_class, 'path')):
            api_path = request_class().path()
            return f"{base_url}{api_path}"
        
        # 如果没有定义path方法，使用默认路径
        return f"{base_url}/open/org/bank/act-bridge/act-merch-relation/update"
    
    def merchant_activity_update(self, request):
        """
        商户活动修改接口
        
        Args:
            request: MerchantActivityUpdateRequest实例
            
        Returns:
            MerchantActivityUpdateResponse实例
        """
        return self.post(request, MerchantActivityUpdateResponse) 